//
//  KLMVerifyManager.swift
//  KLM
//
//  Created by 朱雨 on 2022/4/20.
//

import Foundation

class KLMVerifyManager {
    
    ///是否是邮箱
    static func isEmail(email: String) -> Bool{
        return email.contains(where: {$0 == "@"})
//        let emailStr = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"
//        let emailPredicate = NSPredicate(format:"SELF MATCHES %@", emailStr)
//        return emailPredicate.evaluate(with: email)
    }
    
    ///是否是手机号
    static func isPhone(phone: String) -> Bool {
        let phoneRegex: String = "^((((13[^4]{1})|(14[5-9]{1})|147|(15[^4]{1})|166|(17\\d{1})|(18\\d{1})|(19[0-9]{1}))\\d{8})|((134[^9]{1}|1410|1440)\\d{7}))$"
        let phoneTest = NSPredicate(format: "SELF MATCHES %@", phoneRegex)
        return phoneTest.evaluate(with: phone)
    }
}
 
